<?php

include_once "../library/DbConnection.php";
include_once "../globals.php";

class Knowledge{
	
	private $db;
	
	public function __construct(){
		session_start();

		$this->db = new DbConnection($GLOBALS["db_server"], $GLOBALS["db_login"], $GLOBALS["db_pass"], $GLOBALS["db_name"]);
		$this->db->connect();

	}
	
	public function saveKnowledge($stream){
		$subject = addslashes($stream["subject"]);
		$knowledge = addslashes($stream["knowledge"]);
		
		$sql = "UPDATE logout_users SET knowQuestion = '".$subject."', knowResponse = '".$knowledge."' WHERE id = '".$_SESSION["user_id"]."'";
		$res = $this->db->query($sql);
		if( $res ) {
			return $sql;
		} else {
			return "error_sql";
		}
	}
	
	public function setErase(){
		$sql = "UPDATE logout_users SET knowFinish = 'true' WHERE id = '".$_SESSION["user_id"]."'";
		//$sql = "UPDATE logout_users SET knowFinish = 'true' WHERE id = 'KDHSR0376453DKhJKDISYT289E23YRTGDSHJIUDYST3RE2EFDGRF'";
		$res = $this->db->query($sql);
	}
		
}

?>